package org.example.controller;

import cn.hutool.core.util.IdUtil;
import org.example.domain.GoodsMaterial;
import org.example.result.Result;
import org.example.service.GoodsMaterialService;
import org.example.service.MarketService;
import org.example.service.ProductionService;
import org.example.service.WorkshopService;
import org.example.dto.ProductionDto;
import org.example.vo.MarketVo;
import org.example.vo.WorkshopVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("product2")
@RestController
public class ProductController {

    @Autowired
    private WorkshopService workshopService;

    @Autowired
    private GoodsMaterialService goodsMaterialService;

    @Autowired
    private ProductionService productionService;

    @Autowired
    private MarketService marketService;

    /**
     * 工作车间下拉列表
     * @param workshopVo
     * @return
     */
    @RequestMapping("workShopList")
    public Result workShopList(WorkshopVo workshopVo){
        List<WorkshopVo> list = workshopService.listWorkShop(workshopVo);
        return Result.success(list);
    }

    /**
     * 零售商集合
     */
    @RequestMapping("marketList")
    public Result marketList(MarketVo marketVo){
        List<MarketVo> list = marketService.listMarket(marketVo);
        return Result.success(list);
    }

    /**
     * 生产商品  减少原材料库存  增加商品库存
     */
    @RequestMapping("creatGoods")
    public Result creatGoods(ProductionDto productionDto){
        //添加到商品库中
        return productionService.addGoods(productionDto);
    }
}
